package cn.actoncode.boot.module.ai.service.ability;

import cn.actoncode.boot.framework.web.core.util.WebFrameworkUtils;
import cn.actoncode.boot.module.ai.dal.dataobject.ability.AbilityUsedRecordDO;
import cn.actoncode.boot.module.ai.dal.mapper.ability.AbilityUsedRecordMapper;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 能力使用记录 Service 实现类
 *
 * @author bin
 */
@Service
@Valid
@Slf4j
public class AbilityUsedRecordServiceImpl implements AbilityUsedRecordService {

    @Resource
    private AbilityUsedRecordMapper abilityUsedRecordMapper;

    @Override
    public Long insertAbilityUsedRecord(Long userId, Long abilityId, Long intelligentAgentId,
                                        Integer type, String prompt, String text) {
        AbilityUsedRecordDO abilityUsedRecordDO = new AbilityUsedRecordDO();
        abilityUsedRecordDO.setUserId(userId);
        abilityUsedRecordDO.setAbilityId(abilityId);
        abilityUsedRecordDO.setIntelligentAgentId(intelligentAgentId);
        abilityUsedRecordDO.setType(type);
        abilityUsedRecordDO.setPrompt(prompt);
        abilityUsedRecordDO.setText(text);
        abilityUsedRecordMapper.insert(abilityUsedRecordDO);
        return abilityUsedRecordDO.getId();
    }

    @Override
    public AbilityUsedRecordDO getAbilityUsedRecord(Long id) {
        return abilityUsedRecordMapper.selectById(id);
    }

    @Override
    public List<AbilityUsedRecordDO> getAbilityUsedRecordList(Long userId) {
        return abilityUsedRecordMapper.getAbilityUsedRecordList(userId);
    }
}
